package com.cgs.query.handler

import java.lang.annotation.Inherited

/**
 * 权限安全检查处理器
 */
interface SecurityHandler : UserInfoHolderAware {

    /**
     * 检查权限
     */
    @Throws(SecurityException::class)
    fun checkPermission(obj: PermissionObject)

}

/**
 * 权限适配接口
 */
interface SecurityAdapter {

    fun adapter(methodName: String, args: Array<Any?>): PermissionObject?
}

/**
 * 普通权限检查
 */
@Inherited//Target必须是Type才有效,so这里无效
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
@MustBeDocumented
annotation class Permission{
}

/**
 * 权限检查对象
 */
class PermissionObject(val projectName: String?) {
    var userId: String? = ""
    var obj: Any? = null
    var type = ""
    var run = false
    /**
     * 允许同一用户操作
     */
    var allowTheSameUserToOperate = false
}
